# ============================================================
# by howlink *
# Filename       : startupdg.sh
#
# Description:  create dataguard primary standbyredo logfile 
# exmple: ./changeArch.sh orcl orcl /u01/app/oracle/product/11g/db_1/dbs/arch
# =============================================================
#! /bin/bash

if [ $# -lt 1 ]; then
    echo "must input 1 parameters"
   exit 1
fi

sid=$1
orauser=`cat /opt/howlink/lb-agent/application.properties | grep "^agent.oracle-user" | awk -F'=' '{ print $2 }' | sed 's/ //g'`
if [ -z "$orauser" ];then
    orauser=`ps -ef | grep ora_pmon | grep -v grep | head -n1 | sed -e 's/^[ \t]*//' | cut -d" " -f1`
fi
if [ -z "$orauser" ];then
    orauser=oracle
fi
orahome=`cat /opt/howlink/lb-agent/application.properties | grep "^agent.oracle-home" | awk -F'=' '{ print $2 }' | sed 's/ //g'`
if [ -z "$orahome" ];then
    orahome=`grep -wi "$sid:"  $otab | grep "^$sid" | head -n1 | cut -f2 -d":"`
fi
echo "DB_NAME=$sid">$orahome/dbs/init$sid.ora
chown $orauser $orahome/dbs/init$sid.ora
su - $orauser -c "sqlplus / as sysdba" <<EOF
startup nomount pfile=$orahome/dbs/init$sid.ora force
exit
EOF
